
app.controller('JFmessageCtrl', function($scope, $http) {
      //新增地址的显示隐藏
       $scope.JFmesBol=false;
       
	//地址的三级联动
	var sheng = document.getElementById('sheng1');
	var shi = document.getElementById('shi1');
	var xian = document.getElementById('xian1');
	function shengFun() {
		var l = provinceList.length;
		var shtml = '';
		for (var i = 0; i < l; i++) {
			shtml += '<option value=' + i + '>' + provinceList[i].name + '</option>';
		}
		sheng.innerHTML = shtml;
		cityFun(0);
	}

	function cityFun(n) {
		var city = provinceList[n].cityList;
		var l = city.length;
		var shtml = '';
		for (var i = 0; i < l; i++) {
			shtml += '<option value=' + i + '>' + city[i].name + '</option>';
		}
		shi.innerHTML = shtml;
		xianFun(n, 0);
	}

	function xianFun(n, m) {
		var city = provinceList[n].cityList[m].areaList;
		var l = city.length;
		var shtml = '';
		for (var i = 0; i < l; i++) {
			shtml += '<option>' + city[i] + '</option>';
		}
		xian.innerHTML = shtml;
	}

	 //设置默认
	 shengFun();
	//点击效果
	sheng.onchange = function() {
		var n = this.selectedIndex;
		cityFun(n);
		shi.onchange = function() {
			var m = this.selectedIndex;
			xianFun(n, m);
		};
	};
	
	//检索数据库查询数据地址
	$scope.bol1 = false;
	var tel = localStorage.getItem('tel')
	$http.get('../php/g_message1.php?tel=' + tel + '&token=0').success(function(data) {
		$scope.Adressdata = data;

		if (data.length == 0) {
			$scope.bol1 = false;
		} else if (data.length >= 0) {
			$scope.bol1 = true;
		}
	})
	
	
     //切换选中地址
	$scope.Mesfun = function(e) {
			$('.g_JFmes_contC>img').attr('src', '../img/f_myaccount/circle0.png')
			$(e.target).attr('src', '../img/f_myaccount/circle1.png')
		}   
       //默认地址信息切换
	$scope.Mesfun3= function(a) {
		console.log(111)
		$scope.Adressdata[a].moren = 'true';

		if (a == 0) {
			for (var i = 1; i < $scope.Adressdata.length; i++) {
				$scope.Adressdata[i].moren = '';
			}
		} else {
			for (var i = 0; i < a; i++) {
				$scope.Adressdata[i].moren = '';
			}
			for (var j = a + 1; j < $scope.Adressdata.length; j++) {
				$scope.Adressdata[j].moren = '';
			}
		}
	}

      //s商品初始数量
       $scope.c0=1;
       $scope.c1=1;
       $scope.c2=1;




})